import { ApiCall } from "tsrpc";
import { ReqStart, ResStart } from "../../../../shared/master/copy/dna/PtlStart";
import { player } from "../../../../model/fight/body/player";
import manage_word from "../../../model/manage/manage_word";
import { template } from "../../../../shared/master/MsgAction";
import god from "../../../../god";

export default async function (call: ApiCall<ReqStart, ResStart>) {
    call.succ({})
    let user = call.req._player as player;
    let leve = user.get_DNA_Lv();
    let nowInfo = god.getDNA_info(leve)
    if(leve > 1){
        user.sendMsg(template.default, `基因锁一阶段已完成,后面的还没写(专心上班去了`)
        return;
    }
    // 设置任务完成监听
    let info = await manage_word.transfer(user, nowInfo.test_map)
    if (!info.jude) {
        debugger;
        return;
    }
    user.sendMsg(template.default, info.msg)
    let task = user.getWordTask();
    if (!task) {
        debugger;
        return
    }
    task.onLisentEnd((time: number) => {
        if (time < nowInfo.test_time * 60) {
            user.upLeve_dna();
        } else {
            user.sendMsg(template.default, `[基因锁·试炼]已超时,试炼失败`)
        }
    })
}